package com.mini.cn.goods.io.netty.ws;

import io.netty.handler.codec.http.HttpHeaders;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.

 * User: fly
 * Date: 2020-01-16
 * Time: 7:23 下午
 */
public interface IWsHandel {

    /**
     * ws 握手失败
     *
     * @param session
     */
    void onHandShakeFail(WebSocketSession session);

    /**
     * ws 握手成功
     *
     * @param session
     * @param headers
     * @param parameterMap
     * @throws IOException
     */
    void onOpen(WebSocketSession session, HttpHeaders headers, ParameterMap parameterMap)
            throws IOException;

    /**
     * 二进制发送
     *
     * @param session
     * @param bytes
     */
    void onBinary(WebSocketSession session, byte[] bytes);

    /**
     * 所有事件回调
     *
     * @param session
     * @param evt
     */
    void onEvent(WebSocketSession session, Object evt);

    /**
     * @param session
     * @param message
     */
    void onMessage(WebSocketSession session, String message);


    /**
     * ping包过来的时候
     *
     * @param session
     */
    void onPingMessage(WebSocketSession session);

    /**
     * socket close
     *
     * @param session
     * @throws IOException
     */
    void onClose(WebSocketSession session) throws IOException;

    /**
     * socket error
     *
     * @param session
     * @param throwable
     */
    void onError(WebSocketSession session, Throwable throwable);

}
